import {request} from '../utils/request2'

export const baseUrl = 'https://www.xinmabang.cn'

// login
export const getLoginToken = (code, openid = 0, data) => {
  return request.get('/api/user/login/code/' + code + '/openid/' + openid, data)
}

// 更新用户微信数据
export const updateWXInfo = (nickname, avatar, headers) => request.post('/api/user/update', {nickname, avatar}, headers)

/**********用户**********/
  // 用户-短信发送
export const getSmsCode = (phone) => request.get('/api/user/sms', {phone})

// 用户-短信验证
export const validateSmsCode = (data) => request.get('/api/user/verify_sms', data) // /phone/xxx/code/xxx

// 用户-基本信息
export const getRemoteUserInfo = () => request.get('/api/user/info')

// 用户-基本信息
export const setUserRole = (id) => request.get('/api/user/edit_group/group/' + id)

// 用户-修改基本信息
export const editRemoteUserInfo = (data) => request.post('/api/user/edit', data)

// 用户-修改基本信息 - 商家
export const editRemoteShangjiaUserInfo = (data) => request.post('/api/user/edit_s', data)

// 用户-签到
export const userSign = () => request.get('/api/user/sign')

/**
 * 用户-修改认证照片 (图片参数是否要传base64)
 * @param data {object}
 * {
 * id_pic: '',
 * car_js_pic: '',
 * car_xc_pic: '',
 * }
 * */

export const editVerifyPic = (data) => request.post('/api/user/edit_verify_pic', data)

// 用户-解除绑定/认证
export const removeVerifyPic = () => request.get('/api/user/remove_verify')

// 用户-消息列表
export const getUserMsgList = (data) => request.get('/api/user/msg_list', data) // /type/1/page/1/page_size/10

// 用户-发过的贴
export const getUserArticleList = (data) => request.get('/api/user/article', data) // type: 1交流贴，2曝光贴

// 用户-参与的贴子
export const getUserArticleAbout = (data) => request.get('/api/user/about', data) // type: 1交流贴，2曝光贴

/***********首页**********/
  // banner
export const getBanner = () => request.get('/api/ad/banner_list')

// 首页公告
export const getNotice = () => request.get('/api/ad/notice_list')

// 统计数据
export const getStatData = () => request.get('/api/article/total')

// 首页帖子列表
export const getArticleList = (data) => request.get('/api/article/all_list', data) // /type/time/page/1/page_size/10

/***********交流**********/
  // 交流-按指定标签
export const getListByTag = (data) => request.get('/api/article/list_tag', data) // /tag/1/page/1/page_size/10

// 交流-按时间先后
export const getListByTime = (data) => request.get('/api/article/list_time', data) // /order/desc/page/1/page_size/10

// 交流-按点击量
export const getListByHits = (data) => request.get('/api/article/list_view', data) // /tag/1/page/1/page_size/10

// 交流-按距离最近
export const getListByDistance = (data) => request.get('/api/article/list_position', data) // /tag/1/page/1/page_size/10

/*获取帖子列表*/
export const getArticleListByType = (data) => request.get('/api/article/get_article_list', data) // /tag/1/page/1/page_size/10
/***********曝光**********/
  // 曝光-按指定标签
export const getBgListByTag = (data) => request.get('/api/article/bg_list_tag', data) // /tag/1/page/1/page_size/10

// 曝光-按时间先后
export const getBgListByTime = (data) => request.get('/api/article/bg_list_time', data) // /order/desc/page/1/page_size/10

// 曝光-按点击量
export const getBgListByHits = (data) => request.get('/api/article/bg_list_view', data) // /tag/1/page/1/page_size/10

// 曝光-按距离最近
export const getBgListByDistance = (data) => request.get('/api/article/bg_list_position', data) // /tag/1/page/1/page_size/10

// 曝光-发表帖子
export const publishBgArticle = (data) => request.post('/api/article/publish_bg', data) // title, content, tag,
                                                                                        // position, position_x,
                                                                                        // position_y, bg_goods_info,
                                                                                        // bg_phone

// 交流-发表帖子
export const publishJlArticle = (data) => request.post('/api/article/publish', data) // title, content, tag, position,
                                                                                     // positionx, positiony,
                                                                                     // bg_goods_info, bg_phone

// 搜索帖子
export const searchArticle = (data) => request.post('/api/article/search', data) // type, keywords, page, page_size

// 搜索帖子
export const getArticleDetail = (data) => request.get('/api/article/detail', data) // id

// 增加分享数量
export const addShare = (data) => request.get('/api/article/add_share', data) // /id

// 点赞
export const dianZan = (data) => request.get('/api/article/pick', data) // /aid/5

// 评论
export const publishComment = (data) => request.post('/api/article/comment', data) // aid, content

// 评论
export const publishReplyComment = (data) => request.post('/api/article/reply', data) // aid, content, pid

// 交流贴-标签列表
export const getTagList = () => request.get('/api/article/tag_list')

// 曝光贴-标签列表
export const getTagBgList = () => request.get('/api/article/tag_list_bg')

// 上传图片
// {'Content-Type': 'mutipart'}
// export const uploadImages = (data, headers) => request.post('/api/article/upload_img', data, headers)


